<template>
  <a-select v-model:value="val" :disabled="disabled" :options="list" :field-names="{label:'dictName',value:'dictCode'}" />
</template>

<script lang="ts" setup>
import { getTotalDicts } from '@/api/dict'
import { computed, onMounted, ref } from 'vue'
import { Dict } from '@/config/common'

const props = defineProps({
  modelValue: String,
  disabled: Boolean
})

const val = computed({
  set: val => emits('update:modelValue', val),
  get: () => props.modelValue
})

const list = ref<Dict[]>([])

const loadData = async () => {
  list.value = await getTotalDicts()
}

onMounted(() => {
  loadData()
})

const emits = defineEmits(['update:modelValue'])
</script>

<style scoped>

</style>
